package com.hu.zhcc.shiro.controller;

import com.github.pagehelper.PageInfo;
import com.hu.zhcc.shiro.entity.bo.AssessResult;
import com.hu.zhcc.shiro.service.AssessResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/assessResult")
public class AssessResultController {
    @Autowired
    AssessResultService assessResultService;

    @GetMapping("listAllAssessResult")
    public ResponseEntity<PageInfo<AssessResult>> listAllAssessResult(@RequestParam(required = false) String name,
                                                                      @RequestParam(required = false) String sort, int offset, int limit,Integer type) {
        PageInfo<AssessResult> resultByName = assessResultService.getAssessResultByName(offset, limit, name, type);
        return ResponseEntity.ok(resultByName);
    }
    @GetMapping("getAssessResult")
    public ResponseEntity<AssessResult> getAssessResult(Integer id){
        AssessResult assessResult = assessResultService.getAssessResult(id);
        return ResponseEntity.ok(assessResult);
    }
    @PostMapping("updateAssessResult")
    public ResponseEntity<Integer> updateAssessResult(@RequestBody AssessResult assessResult) {
        int i = assessResultService.updateAssessResult(assessResult);
        return ResponseEntity.ok(i);
    }
    @PostMapping("addAssessResult")
    public ResponseEntity<Integer> addAssessResult(@RequestBody AssessResult assessResult){
        int i = assessResultService.addAssessResult(assessResult);
        return ResponseEntity.ok(i);
    }
    @PostMapping("deleteAssessResult")
    public ResponseEntity<Integer> deleteAssessResult(Integer id){
        int i = assessResultService.deleteAssessResult(id);
        return ResponseEntity.ok(i);
    }
}
